const method = ['GET', 'POST', 'PUT', 'DELETE', 'CONNECT', 'HEAD', 'OPTIONS', 'TRACE']

const disassemblyParams = (_arguments : IArguments) => {
	let params = {
		method: 'GET',
		requestParams: <any>null,
		other: <any>null,
	}
	for (let item of _arguments) {
		/* 筛选请求方式 */
		if (method.indexOf(item) != -1) {
			params.method = item
		}
		/* 筛选请求数据 */
		if (typeof item === 'object' && !Array.isArray(item) && params.requestParams === null) {
			params.requestParams = item
		} else if (typeof item === 'object' && !Array.isArray(item) && params.other === null) {
			params.other = item
		}
	}

	if (!params.requestParams)
		params.requestParams = {}
	if (!params.other)
		params.other = {}

	return params
}

export default disassemblyParams